/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.gar.beans;

import edu.upn.sigemfi.gar.bc.GarantiaDelegate;
import edu.upn.sigemfi.gar.be.Aval;
import edu.upn.sigemfi.gar.be.Garantia;
import edu.upn.sigemfi.gar.be.GarantiaHipotecaria;
import edu.upn.sigemfi.gar.be.GarantiaLiquida;
import edu.upn.sigemfi.gar.be.GarantiaPignoraticia;
import edu.upn.sigemfi.gar.be.GarantiaPrendaria;
import java.util.List;

/**
 *
 * @author Programador
 */
public class GarantiaController {

    private GarantiaDelegate delegado;
    private GarantiaPrendaria garantiaPrendaria;
    private GarantiaPignoraticia garantiaPignoraticia;
    private GarantiaLiquida garantiaLiquida;
    private GarantiaHipotecaria garantiaHipotecaria;
    private Aval aval;

    public GarantiaController()
    {
        delegado = new GarantiaDelegate();
    }

    public Aval getAval() {
        return aval;
    }

    public void setAval(Aval aval) {
        this.aval = aval;
    }

    public GarantiaPrendaria getGarantiaPrendaria() {
        return garantiaPrendaria;
    }

    public void setGarantiaPrendaria(GarantiaPrendaria garantiaPrendaria) {
        this.garantiaPrendaria = garantiaPrendaria;
    }
    
    // Garantias Prendarias
    public List<GarantiaPrendaria> getGarantiasPrendarias() throws Exception{
        try{
            return delegado.listarPrendarias();
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return null;
    }

    public String nuevaGarantiaPrendaria() {
        garantiaPrendaria = new GarantiaPrendaria();
        return "nuevo";
    }

    public String registrarGarPrendaria() {
        try {
            delegado.crearGarantiaPrendaria(garantiaPrendaria);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    public String actualizarGarPrendaria() {
        try {
            delegado.editarGarantiaPrendaria(garantiaPrendaria);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    public String eliminarGarPrendaria() {
        try {
            delegado.eliminarGarantiaPrendaria(garantiaPrendaria);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    // Avales
    public List<Aval> getAvales() throws Exception{
        try{
            return delegado.listarAvales();
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return null;
    }

    public String nuevoAval() {
        aval = new Aval();
        return "nuevo";
    }

    public String registrarAval() {
        try {
            delegado.crearAval(aval);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    public String actualizarAval() {
        try {
            delegado.editarAval(aval);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    public String eliminarAval() {
        try {
            delegado.eliminarAval(aval);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    // Garantias Hipotecarias
    public List<GarantiaHipotecaria> getGarantiasHipotecarias() throws Exception{
        try{
            return delegado.listarHipotecarias();
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return null;
    }
}
